<template>
  <el-container class="home-container">
    <!-- 头部区域 -->
    <el-header>
      <!-- 这里也可以是一个组件不过需要我自己再去封装一下  这个玩意是要包header要分开-->
    <div class="header-logo">
      <img src="~assets/img/home/soCoolTuZi.jpg" alt="">
      <span>电商管理系统</span>
    </div>
    <el-button type="info" @click="quitClick">退出</el-button>
    </el-header>
    <el-container>
      <!-- 侧边栏区域 -->
      <el-aside :width="iscollapse? '64px' : '200px' ">
        <div class="toggle-button" @click="ismenu">|||</div>
        <!-- 这是侧边栏的组件 -->
        <homeaside :menus='menus' :iscollapse='iscollapse'></homeaside>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
// import HomeHeader from './childcoms/HomeHeader'
import homeaside from './childcoms/aside'
export default {
  name: 'home',
  data () {
    return {
      menus: [],
      iscollapse: false
    }
  },
  created () {
    this.getMenusData()
  },
  mounted () {
  },
  methods: {
    quitClick () {
      // 清除我这个里面的数据
      window.sessionStorage.clear()
      // 这里跳转的话就不需要刷新了  就可以跳转了
      this.$router.push('/login')
    },
    // 获取侧边栏的数据
    async getMenusData () {
      const { data: res } = await this.$http.get('menus')
      if (res.meta.status !== 200) return this.$message.error(res.meta.msg)
      this.menus = res.data
      // console.log(this.menus)
    },
    ismenu () {
      this.iscollapse = !this.iscollapse
    }
  },
  components: {
    // HomeHeader
    homeaside
  }
}
</script>

<style scoped>
  .home-container {
    height: 100%!important;
  }
  .el-aside {
    background-color: #74b9ff;
  }
  .el-main {
    background-color: #dfe6e9;
  }
  .el-header {
    background-color: #2ecc71;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 0px;
    color: white;
    font-size: 20px;
  }
  .header-logo {
    display: flex;
    align-items: center;
  }
  .header-logo img {
    height: 50px;
    width: 50px;
    padding-left: 5px;
    border-radius: 30px;
  }
  .header-logo span {
    padding-left: 10px;
    box-shadow: 0, 0, 15px, rgba(0, 0, 0, .5);
  }
  .toggle-button {
    backdrop-filter: gray;
    font-size: 10px;
    line-height: 24px;
    color: white;
    text-align: center;
    cursor: pointer;
    letter-spacing: 0.3rem;
  }
</style>
